package com.chuji.crmcj.receiver;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.chuji.crmcj.utils.UIUtils;
/*
 * 功能：监听短信状态
 * 说明：自定义类ReceiverListner，覆盖BroadcastReceiver，短信发送成功提醒“发送成功”，否则提醒重新发送
 */
public class ReceiverListner extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            // 获取短信状态
            switch (getResultCode()) {
                // 短信发送成功
                case Activity.RESULT_OK:
                    Toast.makeText(UIUtils.getContext(), "发送成功", Toast.LENGTH_LONG).show();
                    System.out.println("发送成功");
                    break;
                // 短信发送不成功
                default:
                    Toast.makeText(UIUtils.getContext(), "发送失败，请重新发送！", Toast.LENGTH_LONG).show();
                    System.out.println("发送失败");
                    break;
            }
        } catch (Exception e) {
            Toast.makeText(UIUtils.getContext(), "发送出现异常，请重新发送！", Toast.LENGTH_LONG).show();
        }
    }
}